package com.qn.strategy.factory;

import com.qn.strategy.ICouponDiscount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class HandleServiceStrategyFactory  {

    private Logger logger = LoggerFactory.getLogger(HandleServiceStrategyFactory.class);

    private static Map<String, ICouponDiscount> services = new ConcurrentHashMap<>();
    public static ICouponDiscount getHandleByCommand(String command){
        return services.get(command);
    }
    public static void register(String command,ICouponDiscount iCouponDiscount){
        Assert.notNull(command,"消息类型不能为空");
        services.put(command,iCouponDiscount);
    }
}
